package com.east.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializeFilter;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.github.pagehelper.Page;

public class PageJson<T> {
	public Page<T> list;
	/**
     * 页码，从1开始
     */
    private int pageNum;
    /**
     * 页面大小
     */
    private int pageSize;
    /**
     * 总数
     */
    private long totalNums;
    /**
     * 总页数
     */
    private int pageCount;
    
	public PageJson() {
		// TODO Auto-generated constructor stub
	}
	
	public PageJson(Page<T> list, int pageNum, int pageSize, long totalNums,
			int pageCount) {
		super();
		this.list = list;
		this.pageNum = pageNum;
		this.pageSize = pageSize;
		this.totalNums = totalNums;
		this.pageCount = pageCount;
	}
	


	public Page<T> getList() {
		return list;
	}

	public void setList(Page<T> list) {
		this.list = list;
	}

	public int getPageNum() {
		return pageNum;
	}

	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public long getTotalNums() {
		return totalNums;
	}

	public void setTotalNums(long totalNums) {
		this.totalNums = totalNums;
	}

	public int getPageCount() {
		return pageCount;
	}

	public void setPageCount(int pageCount) {
		this.pageCount = pageCount;
	}

	public Object pageJson(Page<T> page){
			String jsonString = JSON.toJSONString(page,new SerializeFilter[]{}, new SerializerFeature[]{SerializerFeature.WriteMapNullValue});
			@SuppressWarnings("unchecked")
			PageJson<T> pageFilter = new PageJson<T>(JSONObject.parseObject(jsonString, Page.class),page.getPageNum(),page.getPageSize(),page.getTotal(),page.getPages());
	     return pageFilter;
	}
	
	
}
